﻿
namespace TestFsRx

open System
open System.Reactive
open System.Reactive.Linq
open FSharp.Reactive
open FsUnit

module TestHelpers =

    let shouldObserve expectNext expectError expectCompleted (observable : IObservable<'t>)=
        let next = ref 0
        let error = ref false
        let completed = ref false

        observable
        |> Observable.subscribe (fun _ -> incr next) (fun _ -> error := true) (fun()-> completed :=true)
        |> ignore

        !next |> should equal expectNext
        !error |> should equal expectError
        !completed |> should equal expectCompleted

    let makeErrorStream<'value,'error when 'error :> Exception and 'error : (new : unit -> 'error)>() =
        Observable.Throw<'value>(new 'error())
        



